<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/javascript/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/javascript/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/javascript/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/javascript/images/logo.svg" color="#222">

<link rel="stylesheet" href="/javascript/css/main.css">


<link rel="stylesheet" href="/javascript/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/javascript/","scheme":"Muse","version":"7.7.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="for..of循环只能是数组，对象不行，因为会默认存在迭代器对象  this的指向（由大到小） 默认绑定: 全局调用this，函数直接调用 隐式绑定: 调用函数的上下文对象 显示绑定: 使用call,apply,bind new构造函数: 指向新创建的对象  他们的优先级1 new构造函数 2 显示绑定 3 隐式绑定 4 默认绑定 javaScript中的类型 number string boo">
<meta property="og:type" content="article">
<meta property="og:title" content="你不知道的javascript">
<meta property="og:url" content="http://yoursite.com/2020/10/08/%E4%BD%A0%E4%B8%8D%E7%9F%A5%E9%81%93%E7%9A%84javascript/index.html">
<meta property="og:site_name" content="javascript">
<meta property="og:description" content="for..of循环只能是数组，对象不行，因为会默认存在迭代器对象  this的指向（由大到小） 默认绑定: 全局调用this，函数直接调用 隐式绑定: 调用函数的上下文对象 显示绑定: 使用call,apply,bind new构造函数: 指向新创建的对象  他们的优先级1 new构造函数 2 显示绑定 3 隐式绑定 4 默认绑定 javaScript中的类型 number string boo">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-10-08T15:09:29.595Z">
<meta property="article:modified_time" content="2020-10-10T14:17:15.777Z">
<meta property="article:author" content="HC">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://yoursite.com/2020/10/08/%E4%BD%A0%E4%B8%8D%E7%9F%A5%E9%81%93%E7%9A%84javascript/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'en'
  };
</script>

  <title>你不知道的javascript | javascript</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <div>
      <a href="/javascript/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">javascript</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/javascript/" rel="section"><i class="fa fa-fw fa-home"></i>Home</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/javascript/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>Archives</a>

  </li>
  </ul>

</nav>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="en">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2020/10/08/%E4%BD%A0%E4%B8%8D%E7%9F%A5%E9%81%93%E7%9A%84javascript/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/javascript/images/avatar.gif">
      <meta itemprop="name" content="HC">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="javascript">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          你不知道的javascript
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2020-10-08 23:09:29" itemprop="dateCreated datePublished" datetime="2020-10-08T23:09:29+08:00">2020-10-08</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2020-10-10 22:17:15" itemprop="dateModified" datetime="2020-10-10T22:17:15+08:00">2020-10-10</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <ul>
<li>for..of循环只能是数组，对象不行，因为会默认存在迭代器对象</li>
</ul>
<h2 id="this的指向（由大到小）"><a href="#this的指向（由大到小）" class="headerlink" title="this的指向（由大到小）"></a>this的指向（由大到小）</h2><ul>
<li>默认绑定: 全局调用this，函数直接调用</li>
<li>隐式绑定: 调用函数的上下文对象</li>
<li>显示绑定: 使用call,apply,bind</li>
<li>new构造函数: 指向新创建的对象</li>
</ul>
<h3 id="他们的优先级"><a href="#他们的优先级" class="headerlink" title="他们的优先级"></a>他们的优先级</h3><p>1 new构造函数</p>
<p>2 显示绑定</p>
<p>3 隐式绑定</p>
<p>4 默认绑定</p>
<h2 id="javaScript中的类型"><a href="#javaScript中的类型" class="headerlink" title="javaScript中的类型"></a>javaScript中的类型</h2><ul>
<li><p>number string boolean null undefined object symbol</p>
</li>
<li><p>typeof中的类型: number string boolean undefind object function  symbol</p>
<p><strong>注意的是，<code>typeof null === &#39;object&#39;</code> 判断null的类型要用符合条件去判断: <code>(!a &amp;&amp; typeof a === &#39;object&#39;)</code></strong></p>
</li>
</ul>
<h2 id="常量对象"><a href="#常量对象" class="headerlink" title="常量对象"></a>常量对象</h2><ul>
<li><p>设置常量不可以删改查, 用<code>Object.defineProperty</code>设置<code>writable:false; configurable: false</code></p>
</li>
<li><p>禁止扩展: 禁止一个对象添加新属性并且保留已有属性</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">Object</span>.preventExtensions(obj)</span><br></pre></td></tr></table></figure>
</li>
<li><p>密封: 密封一个对象，会在现有对象上调用<code>Object.preventExtensions()</code>,并把现有属性标记为configurable: false, 密封后不能增和删，但是能改</p>
</li>
<li><p>冻结:  创建一个冻结对象，实际上调用<code>Object,seal()</code>,属性标记为writable: false;,这样久无法修改值，即无法增删改查</p>
</li>
</ul>
<h2 id="小细节"><a href="#小细节" class="headerlink" title="小细节"></a>小细节</h2><ul>
<li><p><code>null == undefined</code>为true, 但是<code>null === undefined</code>为false;</p>
</li>
<li><p>NaN啥也不等，就连<code>NaN === NaN</code>都为false</p>
</li>
<li><p>一个未声明的变量typeof不会报错，得到的是undefined</p>
</li>
<li><p>数组赋值时如果不是用数字索引赋值时，虽然可以访问，但是数组的长度不会变 如:<code>const arr = [] arr[&#39;a&#39;] = &#39;aa&#39;</code>这样得到的数组长度仍然为0,但是可以通过arr[‘a’]访问到值’aa’；<strong>特别注意的是，如果arr[‘数字’] = ‘…’ 这样赋值的话，数组的长度就是数字+1了</strong></p>
</li>
<li><p>字符串借用数组的方法处理时有一项是不会改变的</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> str = <span class="string">'abc'</span>;</span><br><span class="line"><span class="keyword">let</span> result = <span class="built_in">Array</span>.prototype.reverse(str);</span><br><span class="line"><span class="comment">// 返回的还是'abc'字符串</span></span><br><span class="line"><span class="comment">// 如果实在是像这样做,可以先将字符串用split转为数组，然后调用reverse,最后调用join拼接起来</span></span><br><span class="line">str.split(<span class="string">''</span>).reverse().join(<span class="string">''</span>);</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">- 将很大的数字转为指数形式</span><br><span class="line"></span><br><span class="line">  &#96;&#96;&#96;js</span><br><span class="line">  let num &#x3D; 60000000000</span><br><span class="line">  num.toExponential() &#x2F;&#x2F; 转为指数</span><br></pre></td></tr></table></figure>
</li>
<li><p>显示有效的位数</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> a = <span class="number">42.59</span>;</span><br><span class="line">a.toPrecision(<span class="number">1</span>) <span class="comment">// 4e+1</span></span><br><span class="line">a.toPrecision(<span class="number">2</span>) <span class="comment">// 43</span></span><br><span class="line"><span class="comment">// 特别注意的是，不能直接使用数字去点方法 如21.xxx(), 要有两个小数点</span></span><br><span class="line"><span class="comment">//但是可以使用(21).xxx() || 21..xxx() ||</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>js中进制的表示: <code>ob11(二进制) o066(八进制) oxaa(十六进制)</code></p>
</li>
<li><p>判断一个数字是否值整数</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// es6之前</span></span><br><span class="line"><span class="built_in">Number</span>.isInteger = <span class="function"><span class="keyword">function</span> (<span class="params">number</span>) </span>&#123;</span><br><span class="line">	<span class="keyword">return</span> <span class="keyword">typeof</span> number === <span class="string">'number'</span> &amp;&amp; num % <span class="number">1</span> === <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// est之后</span></span><br><span class="line"><span class="built_in">Number</span>.isInteger(number);</span><br></pre></td></tr></table></figure>
</li>
<li><p>js中安全的数字 -(2^53 - 1) –&gt; 2^53 - 1</p>
</li>
<li><p>undefined和null的区别: </p>
<ul>
<li>undefined从未赋值过，但是null表示赋值过，但是现在是空值</li>
<li>undefined可以当作变量来使用，null不行。<strong>但是强烈推荐不要这样做</strong></li>
</ul>
</li>
<li><p><code>typeof NaN === ‘number&#39;</code>，可称NaN是无效数值，失败数值或者坏数值</p>
</li>
<li><p><code>window.isNaN(num)</code>有一个bug，就是如果是字符串，也返回true, 因此可以使用Es6的<code>Number.isNaN(num)</code>来判断</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// es5 polyfill代码为</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isNaN</span>(<span class="params">number</span>) </span>&#123;</span><br><span class="line">	<span class="keyword">return</span> <span class="keyword">typeof</span> number === <span class="string">'number'</span> &amp;&amp; <span class="built_in">window</span>.isNaN(number)</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 或者可以这样 利用NaN不等于自己的特性</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isNaN</span>(<span class="params">number</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> number !== number;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>es6提供了工具方法<code>Object.is(n1, n2)</code>一般用来判断两个特殊的值是否绝对相等 判断<code>NaN  -0 和 0</code>。<strong>能使用 == 和 === （参见第 4 章）时就尽量不要使用 Object.is(..) ，因为前者效率更高、<br>更为通用。 Object.is(..) 主要用来处理那些特殊的相等比较</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">Object</span>.is(n1, n2);</span><br><span class="line"><span class="keyword">let</span> str = <span class="number">2</span> / <span class="string">'foo'</span>;</span><br><span class="line"><span class="built_in">Object</span>.is(str, <span class="literal">NaN</span>); <span class="comment">// true</span></span><br><span class="line"><span class="built_in">Object</span>.is(<span class="string">'abc'</span>, <span class="literal">NaN</span>) <span class="comment">// false</span></span><br><span class="line"><span class="built_in">Object</span>.is(<span class="number">0</span>, <span class="number">-0</span>)  <span class="comment">// false</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// Object.is()的polyfill代码</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isObject</span>(<span class="params">v1, v2</span>) </span>&#123;</span><br><span class="line">    <span class="comment">// 比较0和-0</span></span><br><span class="line">    <span class="keyword">if</span> (v1 === <span class="number">0</span> &amp;&amp; v2 === <span class="number">0</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="number">1</span> / v1 === <span class="number">1</span> / v2;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 比较NaN</span></span><br><span class="line">    <span class="keyword">if</span> (v1 !== v1) &#123;</span><br><span class="line">        <span class="keyword">return</span> v2 !== v2</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 其他情况</span></span><br><span class="line">    <span class="keyword">return</span> v1 === v2;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>判断一个数是不是NaN的四种有效方法</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 1</span><br><span class="line">Object.is(n1, NaN);</span><br><span class="line">&#x2F;&#x2F; 2</span><br><span class="line">Number.isNaN(n1);</span><br><span class="line">&#x2F;&#x2F; 3</span><br><span class="line">function isNaN(number) &#123;</span><br><span class="line">	return typeof number &#x3D;&#x3D;&#x3D; &#39;number&#39; &amp;&amp; window.isNaN(number);</span><br><span class="line">&#125;</span><br><span class="line">&#x2F;&#x2F; 4 </span><br><span class="line">function isNaN2(number) &#123;</span><br><span class="line">	reture number !&#x3D;&#x3D; number; </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>\n对应的十六进制为0x0a，\r对应的十六进制为0x0d。window系统换行是会有\n和\r，但是mac系统只有\r</p>
</li>
</ul>
<h2 id="原生函数-javascript的内建函数"><a href="#原生函数-javascript的内建函数" class="headerlink" title="原生函数(javascript的内建函数)"></a>原生函数(javascript的内建函数)</h2><ul>
<li>Number()</li>
<li>String()</li>
<li>Boolean()</li>
<li>Object()</li>
<li>Array()</li>
<li>Function()</li>
<li>RegExp()</li>
<li>Date()</li>
<li>Error()</li>
<li>Symbol()</li>
</ul>
<h2 id="正则表达式"><a href="#正则表达式" class="headerlink" title="正则表达式"></a>正则表达式</h2><ul>
<li><p>(?:xx) 表示匹配不捕获</p>
</li>
<li><p>(?=xx) 正向预查,<strong>一次正向预查(?=xx)就对整个字符串预</strong></p>
<p>匹配任何其后紧接指定字符串 xx的字符串。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> reg = <span class="regexp">/(?=k)kd/</span>; <span class="comment">// 这样才能匹配到</span></span><br><span class="line"><span class="keyword">const</span> str = <span class="string">'jfsdkd'</span> </span><br><span class="line"><span class="keyword">const</span> reg2 = <span class="regexp">/jfs(?=k)/</span>; <span class="comment">// 这样就行了</span></span><br></pre></td></tr></table></figure>



</li>
</ul>
<ul>
<li><p>(?!xx) 反向预查  <strong>一次正向预查(?!xx)就对整个字符串预查</strong></p>
<p>匹配任何其后没有紧接指定字符串 n 的字符串。</p>
</li>
</ul>
<h2 id="Object-defineProperty-的配置"><a href="#Object-defineProperty-的配置" class="headerlink" title="Object.defineProperty()的配置"></a>Object.defineProperty()的配置</h2><p>默认情况下, 使用Object.defineProperty()没有配置时，其他默认都为false或undefined.configurable, writable, enumerable都是false的。但是普通对象的值的writable, enumerable,configurable都为true</p>
<p><strong>writable 和set   value和get时矛盾的，只能出现其一</strong></p>
<h2 id="快速取反-快速取整数"><a href="#快速取反-快速取整数" class="headerlink" title="快速取反,快速取整数"></a>快速取反,快速取整数</h2><ul>
<li><p>~x =&gt; 取反: -(x + 1). </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 比如求~1</span><br><span class="line">1的二进制数为 00000001(简写了)</span><br><span class="line">一.取反得到11111110</span><br><span class="line">二.如果要求得11111110的值，因为他是以1开头的，是负数，所以要取反加1，即-(00000001 + 1),也就是 -(1 + 1)为-2</span><br></pre></td></tr></table></figure>



</li>
</ul>
<ul>
<li><p>取整: (<del>3.12233) ~3.122233得到 -(3 + 1)为-4, 然后再</del>(-4 + 1) 得到了3</p>
</li>
<li><p>位运算的应用: 权限</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> perm = &#123;</span><br><span class="line">	read: <span class="number">0b001</span>,</span><br><span class="line">	write: <span class="number">0b010</span>,</span><br><span class="line">	create: <span class="number">0b011</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 添加权限 </span></span><br><span class="line"><span class="keyword">const</span> p = perm.read | perm.write;</span><br><span class="line"><span class="comment">//删除权限 1先加读权限(否则如果读没有的话，异或加添加上了) 2 再取异或</span></span><br><span class="line"><span class="keyword">const</span> res2 = p | perm.read ^ perm.read; <span class="comment">//相同的去掉 </span></span><br><span class="line"><span class="comment">// 查看权限</span></span><br><span class="line"><span class="keyword">const</span> res1 = p &amp; perm.read === perm.read; <span class="comment">//如果为true就有可读的权限</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>位移(左位移和右位移)</p>
<ul>
<li>2左移n位,得到的数为 2 * (2^n)</li>
<li>2右移动n位，得到的数为 2 / (2^n)</li>
</ul>
</li>
</ul>
<h2 id="Object-create的第二个参数"><a href="#Object-create的第二个参数" class="headerlink" title="Object.create的第二个参数"></a>Object.create的第二个参数</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> o = <span class="built_in">Object</span>.create(obj, &#123;<span class="attr">xx</span>: &#123;configurable, enumrable, writtable, value...&#125;&#125;)</span><br><span class="line"><span class="comment">// 第二个参数的xx属性会成为创建出的对象的o的访问器属性，同时也能继承至obj的方法属性</span></span><br></pre></td></tr></table></figure>



<h2 id="箭头函数的特点"><a href="#箭头函数的特点" class="headerlink" title="箭头函数的特点"></a>箭头函数的特点</h2><ul>
<li>无this</li>
<li>无arguments</li>
</ul>
<h2 id="let-定义的变量不会放到window中"><a href="#let-定义的变量不会放到window中" class="headerlink" title="let 定义的变量不会放到window中"></a>let 定义的变量不会放到window中</h2>
    </div>

    
    
    

      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/javascript/2020/10/08/javascript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1%E7%AC%AC%E5%9B%9B%E7%89%88/" rel="prev" title="javascript高级程序设计第四版">
      <i class="fa fa-chevron-left"></i> javascript高级程序设计第四版
    </a></div>
      <div class="post-nav-item">
    <a href="/javascript/2020/10/10/%E5%B8%B8%E8%A7%81%E6%89%8B%E5%86%99js%E9%9D%A2%E8%AF%95%E9%A2%98/" rel="next" title="常见手写js面试题">
      常见手写js面试题 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#this的指向（由大到小）"><span class="nav-number">1.</span> <span class="nav-text">this的指向（由大到小）</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#他们的优先级"><span class="nav-number">1.1.</span> <span class="nav-text">他们的优先级</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#javaScript中的类型"><span class="nav-number">2.</span> <span class="nav-text">javaScript中的类型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#常量对象"><span class="nav-number">3.</span> <span class="nav-text">常量对象</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#小细节"><span class="nav-number">4.</span> <span class="nav-text">小细节</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#原生函数-javascript的内建函数"><span class="nav-number">5.</span> <span class="nav-text">原生函数(javascript的内建函数)</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#正则表达式"><span class="nav-number">6.</span> <span class="nav-text">正则表达式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Object-defineProperty-的配置"><span class="nav-number">7.</span> <span class="nav-text">Object.defineProperty()的配置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#快速取反-快速取整数"><span class="nav-number">8.</span> <span class="nav-text">快速取反,快速取整数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Object-create的第二个参数"><span class="nav-number">9.</span> <span class="nav-text">Object.create的第二个参数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#箭头函数的特点"><span class="nav-number">10.</span> <span class="nav-text">箭头函数的特点</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#let-定义的变量不会放到window中"><span class="nav-number">11.</span> <span class="nav-text">let 定义的变量不会放到window中</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">HC</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/javascript/archives/">
        
          <span class="site-state-item-count">12</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">HC</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> v4.2.1
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">Theme – <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> v7.7.2
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/javascript/lib/anime.min.js"></script>
  <script src="/javascript/lib/velocity/velocity.min.js"></script>
  <script src="/javascript/lib/velocity/velocity.ui.min.js"></script>

<script src="/javascript/js/utils.js"></script>

<script src="/javascript/js/motion.js"></script>


<script src="/javascript/js/schemes/muse.js"></script>


<script src="/javascript/js/next-boot.js"></script>




  















  

  

</body>
</html>
